﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using UnityEngine;

public class BaseJob
{
    private TheadedWorker targetWorker=null;
    public Action<object> func = null;
    public object args;

    public void Release()
    {
        if (this.targetWorker!=null)
        {
            targetWorker.CancelJob();
        }
    }
    public bool Excute(TheadedWorker worker)
    {
        if (null!=func)
        {
            this.targetWorker = worker;
            try
            {
                DateTime time = DateTime.Now;
                func(args);
                
            }
            catch (Exception e)
            {
                Debug.LogError(e);
                return false;
            }
            
        }
        return true;
    }
}

